import java.util.Scanner;

public class HihoCoder1268 {
	public static int[] value = new int[11];
	public static int[] temp = new int[11];
	public static boolean[] has = new boolean[10];

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		for (int i = 0; i < 9; i++) {
				value[i] = in.nextInt();
				if(value[i]!=0){
					has[value[i]]=true;
				}
		}
		DFS(0);
	}

	public static boolean DFS(int i) {
		if (i>=9 && examine(value)){ 
			temp=value.clone();
			output();
	        return true;
	    }
		if(value[i]!=0){
			DFS(i + 1);
		}else{
			for (int num = 1; num <= 9; num++) {
				if (!has[num]) {
					has[num] = true;
					value[i] = num;
					DFS(i+1);
					has[num] = false;
					value[i] = 0;
				}
			}
		}
		return false;

	}

	private static void output() {
		for (int i = 0; i < 3; i++) {
			for(int j=0;j<3;j++){
				System.out.print(temp[(i*3)+j]+" ");
			}
				System.out.println();
		}
		System.out.println();

	}

	public static boolean examine(int[] Matrix) {
		if (Matrix[0] + Matrix[1] + Matrix[2] != 15)
			return false;
		if (Matrix[3] + Matrix[4] + Matrix[5] != 15)
			return false;
		if (Matrix[6] + Matrix[7] + Matrix[8] != 15)
			return false;
		if (Matrix[0] + Matrix[3] + Matrix[6] != 15)
			return false;
		if (Matrix[1] + Matrix[4] + Matrix[7] != 15)
			return false;
		if (Matrix[2] + Matrix[5] + Matrix[8] != 15)
			return false;
		if (Matrix[0] + Matrix[4] + Matrix[8] != 15)
			return false;
		if (Matrix[6] + Matrix[4] + Matrix[2] != 15)
			return false;
		return true;
	}

}
